/// @tags: UndirectedTernaryRingCount
#include <cstdio>
#include <iostream>
#include <vector>

using std::cin, std::cout;

namespace BlueQuantum {

constexpr int MAXN = 2e5 + 3;

int n, m, ans;
int deg[MAXN], A[MAXN], B[MAXN], vis[MAXN];
std::vector<int> e[MAXN];

inline int main() {
  cin >> n >> m;
  for (int i = 1; i <= m; ++i) {
    cin >> A[i] >> B[i];
    ++deg[A[i]], ++deg[B[i]];
  }
  for (int u, v; m; --m) {
    u = A[m], v = B[m];
    if (deg[u] > deg[v]) {
      std::swap(u, v);
    } else if ((deg[u] == deg[v]) && (u > v)) {
      std::swap(u, v);
    }
    e[u].push_back(v);
  }
  for (int u = 1; u <= n; ++u) {
    for (auto v : e[u]) vis[v] = u;
    for (auto v : e[u])
      for (auto w : e[v])
        if (vis[w] == u) ++ans;
  }
  cout << ans;
  return 0;
}

}  // namespace BlueQuantum

int main() {
#ifndef ONLINE_JUDGE
#ifdef LOCAL
  freopen("/tmp/CodeTmp/testdata.in", "r", stdin);
  freopen("/tmp/CodeTmp/testdata.out", "w", stdout);
#else
  freopen("UndirectedTernaryRingCount.in", "r", stdin);
  freopen("UndirectedTernaryRingCount.out", "w", stdout);
#endif
#endif

  std::ios::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL);
  return BlueQuantum::main();
}
